import { Controller, Get } from '@nestjs/common';
import { RequiredAuth } from 'src/auth/decorators/auth.decorator';
import { User } from 'src/auth/decorators/user.decorator';
import { UserClaims } from 'src/shared/user';
import { UsersService } from './users.service';

@Controller('users')
export class UsersController {
  constructor(private readonly userService: UsersService) {}

  @Get()
  @RequiredAuth()
  async getMe(@User() { id }: UserClaims) {
    const user = await this.userService.findById(id);

    return { ...user, password: undefined };
  }
}
